package com.hongning.railway.ui.main.mine.partcheck.itemviewmodel;

import android.databinding.ObservableField;
import android.os.Bundle;
import android.support.annotation.NonNull;

import com.hongning.railway.app.Constant;
import com.hongning.railway.entity.resbean.ResKaoHeBean;
import com.hongning.railway.ui.main.mine.partcheck.PartCheckMainFragmentViewModel;
import com.hongning.railway.ui.main.mine.partcheck.PartCheckSecondFragment;
import com.hongning.railway.util.TimeUtils;

import me.goldze.mvvmhabit.base.ItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;

public class PartCheckItemViewModel extends ItemViewModel<PartCheckMainFragmentViewModel> {
    public ObservableField<String> publishtime = new ObservableField<>();
    public ObservableField<String> publishname = new ObservableField<>();
    private ResKaoHeBean mResKaoHeBean;
    public PartCheckItemViewModel(@NonNull PartCheckMainFragmentViewModel viewModel, ResKaoHeBean resKaoHeBean) {
        super(viewModel);
        publishtime.set("发布时间："+ TimeUtils.getFormatTime(resKaoHeBean.getAddTime()));
        publishname.set(resKaoHeBean.getExamName());
        this.mResKaoHeBean = resKaoHeBean;
    }

    public BindingCommand goSecond = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            Bundle bundle = new Bundle();
            bundle.putParcelable(Constant.EXTRA_DATA,mResKaoHeBean);
            viewModel.startContainerActivity(PartCheckSecondFragment.class.getCanonicalName(),bundle);
        }
    });
}
